package com.zk.yygh.order.receiver;

import com.rabbitmq.client.Channel;
import com.zk.yygh.order.service.OrderService;
import com.zk.yygh.rabbit.constant.MqConst;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author: 张凯
 * @date: 2022/6/25 - 9:55
 */
@Component
public class OrderReceiver {

    @Autowired
    private OrderService orderService;

    //监听消息
    @RabbitListener(bindings = @QueueBinding(
            //队列
            value = @Queue(value = MqConst.QUEUE_TASK_8, durable = "true"),
            //交换机
            exchange = @Exchange(value = MqConst.EXCHANGE_DIRECT_TASK),
            //路由key
            key = {MqConst.ROUTING_TASK_8}
    ))
    public void patientTips(Message message, Channel channel){
        //监听到消息后调用业务层方法
        orderService.patientTips();
    }
}
